adi_pwr_Init();
adi_pwr_EnableClockSource(ADI_CLOCK_SOURCE_HFXTAL,true);
adi_pwr_EnableClockSource(ADI_CLOCK_SOURCE_LFXTAL,true);
adi_pwr_SetClockDivider(ADI_CLOCK_HCLK,1);
adi_pwr_SetClockDivider(ADI_CLOCK_PCLK,1);
void init_ADC0(void)
{
	bool ADC_Ready=false;
	mux_PINS(2,3,0x1);
	mux_PINS(2,8,0x1);

	adi_adc_Open(0,&ADC0_MemorySize,ADI_ADC_MEMORY_SIZE,&handle_ADC0);
	adi_adc_PowerUp(handle_ADC0,true);
	adi_adc_SetVrefSource(handle_ADC0,ADI_ADC_VREF_SRC_INT_2_50_V);
	adi_adc_SetResolution(handle_ADC0,ADI_ADC_RESOLUTION_12_BIT);
//	adi_adc_RegisterCallback(handle_ADC0,callback_ADC0,NULL);
	adi_adc_EnableADCSubSystem(handle_ADC0,true);
	ADC_Ready=false;	
	while(!ADC_Ready)
	{
		delay_ms(5);
		adi_adc_IsReady(handle_ADC0,&ADC_Ready);
	}
	
	adi_adc_StartCalibration(handle_ADC0);
	ADC_Ready=false;
	while(!ADC_Ready)
	{
		delay_ms(5);
		adi_adc_IsCalibrationDone(handle_ADC0,&ADC_Ready);
	}
	
	adi_adc_SetDelayTime(handle_ADC0, 10);
	adi_adc_SetAcquisitionTime(handle_ADC0, 10);
	
	printf("###### 电压：BAT1_Voltage	= %f\n",count_ADC0(ADI_ADC_CHANNEL_5,32));	
	printf("###### 电压：VCC_4.2_Voltage	= %f\n",(count_ADC0(ADI_ADC_CHANNEL_5,32)*((200+453)/200)));
	printf("###### 电压：SOLAR_Voltage	= %f\n",count_ADC0(ADI_ADC_CHANNEL_0,32));
	printf("###### 电压：VCC_VIN_Voltage	= %f\n",(count_ADC0(ADI_ADC_CHANNEL_0,32)*((200+453)/200)));
}
float count_ADC0(uint32_t Channel,uint8_t Samples_Num)
{
	uint16_t ADC_Data_Buf[Samples_Num];
	memset(ADC_Data_Buf,0,sizeof(ADC_Data_Buf));
	uint32_t ADC_Sum_Data=0;
	float Voltage=0;
	ADI_ADC_BUFFER ADC_Buf;
	ADI_ADC_BUFFER* pADC_Buf=&ADC_Buf;
	ADC_Buf.nBuffSize=sizeof(ADC_Data_Buf);
	ADC_Buf.nChannels=Channel;
	ADC_Buf.pDataBuffer=ADC_Data_Buf;
	ADC_Buf.nNumConversionPasses=Samples_Num;
	
	adi_adc_SubmitBuffer(handle_ADC0,&ADC_Buf);	
	adi_adc_Enable(handle_ADC0,true);	
  adi_adc_GetBuffer(handle_ADC0, &pADC_Buf);
	adi_adc_Enable(handle_ADC0,false);
	
	for (uint8_t i=0;i<Samples_Num;i++)
	{
		ADC_Sum_Data+=ADC_Data_Buf[i];
	}
	Voltage=ADC_Sum_Data*2.5/4096/Samples_Num;
	
	return Voltage;
}
